package com.office.quartz.task;


import com.office.quartz.domain.PostAReminder;
import com.office.quartz.mapper.PostAReminderMapper;
import com.office.quartz.service.PostAReminderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日程提醒定时任务
 *
 * @author: 柒月
 * @date: 2025/5/31 下午8:54
 * @version: 1.0
 */
@Component("datesTask")
public class DatesTask {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    public PostAReminderService postAReminderService;

    public void postAReminder(){
        // 查询提醒是否有到时间了的
        List<PostAReminder> list =  postAReminderService.checkIfTheReminderIsUpToDate();

        // 如果有说明有提醒要发送
        if(!list.isEmpty()){
            logger.info("有要发送的提醒");
            // 去发送
            postAReminderService.sendAReminder(list);
        }else {
            logger.info("没有要发送的提醒");
        }
    }
}
